package com.letv.core.bean;

import java.io.Serializable;
import java.util.ArrayList;

import com.letv.core.bean.LetvBaseBean;
import com.letv.core.bean.VideoBean;
import com.letv.core.utils.LogInfo;

public class VideoRelatedListBean extends ArrayList<RelateSetBean> implements LetvBaseBean, Serializable {

    private static final long serialVersionUID = 3695482698809595366L;

    private static final String TAG = VideoRelatedListBean.class.getSimpleName();
	
	/**
	 * 猜你喜欢类型
	 */
	public static final int RECT_TITLE_TYPE = 3; 
	public static final int RECT_CONTENT_TYPE = 4; //猜你喜欢
	/**
	 * 相关系列类型
	 */
	public static final int RELATE_TITLE_TYPE = 2;
	public static final int RELATE_CONTENT_TYPE = 1;	
	
	/**
	 * cms 数据类型
	 */
	public static final int CMS_CONTENT_TYPE = 5;
	/**
	 * 当前正在播放类型
	 */
	public static final int SELF_VIDEO_TYPE = 6;
	
	/*
	 * Type的总个数
	 */
	public static final int VIDEO_RELATED_COUNT = 7;
	
	/**
	 * 往期回顾视频
	 */
	public RecAlbumBean recAlbumInfo;
	
	public VideoBean getSelfVideo(){
		for (RelateSetBean relatedBean : this){
			if (relatedBean.type == SELF_VIDEO_TYPE){
				return relatedBean.tabVideoInfoBean;
			}
		}
		return null;
	}
	
	public RecommendInfoListBean getRecommendPlayerLibsList(){
		RecommendInfoListBean recommendInfoListPlayerLibs = new RecommendInfoListBean();
		for (RelateSetBean relatedBean : this){
			if (relatedBean.type == RECT_CONTENT_TYPE){
				recommendInfoListPlayerLibs.add(relatedBean.rect);
			}
		}
		LogInfo.log(TAG, "getRecommendPlayerLibsList size : " + recommendInfoListPlayerLibs.size());
		return recommendInfoListPlayerLibs;
	}
	
	public RecommendBean videoPlayerLibsToRecommendPlayerLibs(VideoBean videoPlayerLibs){
		if (videoPlayerLibs == null){
			return null;
		}
		
		RecommendBean recomment = new RecommendBean();
		recomment.id = (int)videoPlayerLibs.getId();
		recomment.title = videoPlayerLibs.getNameCn();
		recomment.pid = (int)videoPlayerLibs.getPid();
		recomment.cid = videoPlayerLibs.getCid();
		recomment.pay = String.valueOf(videoPlayerLibs.getPlay());
		recomment.duration = String.valueOf(videoPlayerLibs.getDuration());
		recomment.type = videoPlayerLibs.getType();
		recomment.pic320 = videoPlayerLibs.getPic320();
		recomment.videoType = videoPlayerLibs.getVideoType();
		return recomment;
	}
	
	public int getListViewSelectionByVid(long vid){
		int i = 0;
		for (RelateSetBean relatedBean : this){
			if (relatedBean.type == RECT_CONTENT_TYPE){
				if (relatedBean.rect.id == vid){
					return i;
				}
			}
			i++;
		}
		return 0;
	}
	
	public void removeRectTitle(){
		for (RelateSetBean relatedBean : this){
			if (relatedBean.type == RECT_TITLE_TYPE){
				LogInfo.log(TAG, "removeRectTitle RECT_TITLE_TYPE");
				remove(relatedBean);
				break;
			}
		}
	}
	
}
